1. Field of the Invention
The present invention relates to the field of data processing systems. More particularly, the present invention relates to the execution of stack-based instructions within a data processing apparatus arranged to apply operations to data items stored in registers.
2. Description of the Prior Art
One class of instruction sets includes those instruction sets that use a stack-based approach to storing and manipulating data items upon which they act. The stack within a data processing system supporting such a stack-based instruction set may store a sequence of data items, for example operand values, that are placed into the stack in a particular order and then removed from the stack in the reverse of that order. Thus, the last data item to be placed into the stack will also typically be the first data item to be removed from the stack. Stack-based processors may provide a stack consisting of a plurality of addressable stack entries to which data items may be written and from which data items may be read in conjunction with a stack pointer which indicates the current “top” position within the stack. The stack pointer specifies a reference point within the stack memory which identifies the latest data item to be stored into the stack and from which other accesses to the stack may be referenced.
One example of a stack-based instruction set is the Java Virtual Machine instruction set as specified by Sun Microsystems Inc. The Java programming language seeks to provide an environment in which computer software written in Java can be executed upon many different processing hardware platforms without having to alter the Java software. Another example of a stack-based instruction set is the Java Card instruction set as specified by Sun Microsystems Inc., which is a version of Java which has been designed for use within smart cards and similar devices, i.e. devices which are relatively cheap and consume relatively low power.
Another class of instruction sets includes those instruction sets that use a register-based approach to storing and manipulating the data items upon which they act. An example of such register-based systems are the ARM processors produced by ARM Limited of Cambridge, England. ARM instructions execute operations (such as mathematical manipulations, loads, stores, etc) upon operands stored within registers of the processor specified by register fields within the instructions.
It is becoming more desirable for data processing systems designed to execute register-based instructions to support execution of stack-based instructions. An example of such a data processing system is described in UK patent application no. 0024404.6. As described in that patent application, stack-based instructions are converted into a sequence of operations to be executed by the processor core upon registers within a register bank. The data items on the stack that are required by those operations are stored from the stack into registers of the register bank so that they are available to the processor core. Typically, a set of registers within the register bank are allocated to hold stack data items (also referred to herein as stack operands) from a portion of the stack. As described in that patent application, in order to efficiently use the registers allocated to stack operands, a plurality of different mapping states are provided in which different registers within the set hold respective stack operands from different positions within the portion of the stack. The mapping state is changed in dependence upon operations that add or remove stack operands held within the set of registers used for the stack in a manner that provides a function similar to that of a stack pointer within a stack. This approach reduces the processing overhead required to provide stack-like storage within the registers of a register-based processor.
In the system described in UK patent application no. 0024404.6, each of the stack entries in the stack is considered to be of a fixed size, and each register in the set of registers allocated to hold stack operands is arranged to only store the data corresponding to one stack entry. However, it will be appreciated that the registers of the processor core that may be devoted to the storage of stack operands is limited by the need to provide other registers for functions such as the management of the decoding of the stack-based instructions into operations to be executed within the register-based processor, and for the emulation of other control values, such as a variables pointer or a constant pool pointer, that may be found in a stack-based processing system. This means that situations may arise where stack operands held within the set of registers may need to be moved back to the stack to provide room for new stack operands to be placed within the set of registers.
Accordingly, it will be desirable to provide techniques which enable more flexible use of the set of registers allocated for the storage of stack operands.